
const deviceMap = new Map();
deviceMap.set('a', [{ device_conn_key: '111' }, { device_conn_key: '1112' }])
deviceMap.set('b', [{ device_conn_key: '11s1' }, { device_conn_key: '11s12' }])
deviceMap.set('c', [{ device_conn_key: '1asd1s1' }, { device_conn_key: '11sasd12' }])
const conn = [
    { key: '111' },
    { key: '1112' }
]
// 1，筛选出新的deviceMap的key value
// 2, 筛选出废弃的 key arr

deleteArr = [];

for (const device of deviceMap) {
    const d = device[1];
    let arr = [];
    d.forEach(de => {
        let isAlive = false;
        conn.forEach(c => {
            if (c.key == de.device_conn_key) {
                arr.push(de);
                isAlive = true;
            }
        })
        if (!isAlive) deleteArr.push(de.device_conn_key);
    });
    if (arr.length) {
        deviceMap.set(device[0], arr);
    } else {
        deviceMap.delete(device[0]);
    }
}

console.log(deviceMap, deleteArr);